﻿using UnityEngine;
using System.Collections;

/// <summary>
/// Script that stops all parallax movement on gameover.
/// </summary>
public class StopAllPhysics : MonoBehaviour {

	public bool GameOver = false;
	bool StartedGameOver = false;
	float ResetCountdown = 2f;
	ScoreKeeper keeper;

	// Use this for initialization
	void Start () {
		this.keeper = (ScoreKeeper)GameObject.Find("Scripts").GetComponent(typeof(ScoreKeeper));
	}
	
	// Update is called once per frame
	void Update () {
		if (GameOver && !StartedGameOver) {
			StartedGameOver = true;
			this.keeper.SaveHighScore();
		}
		if (StartedGameOver) {
			ResetCountdown -= Time.deltaTime;
			if (ResetCountdown <= 0f)  {
				Application.LoadLevel(0);
			}
		}
	}
}
